package com.elephant.core.nio;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * @author hai
 * @description
 * @date 9:44 2018/9/27
 */
public class FileNio {

    ByteBuffer fbb;

    public static void main(String[] args) {

        try {
            FileInputStream raf = new FileInputStream(new File("D:\\xiaozhan\\H5\\2018-12-26\\access.log"));

            FileChannel fc=raf.getChannel();

            //一次读取文件，读取的字节缓存数
            ByteBuffer fbb=ByteBuffer.allocate(1024*5);
            fc.read(fbb);
            fbb.flip();

            //每行缓存的字节   根据你的实际需求

            ByteBuffer bb=ByteBuffer.allocate(500);


        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
